package com.htc.model.utils;

import java.util.ArrayList;

import android.content.Context;
import android.database.Cursor;

import com.htc.constants.Constants;
import com.htc.model.dto.SpaChildDTO;
import com.htc.model.dto.SpaParentDTO;

public class SpasModel {

	public static SpasModel instance;

	public static SpasModel getInstance() {
		if (instance == null)
			instance = new SpasModel();
		return instance;
	}

	public ArrayList<SpaChildDTO> getAllSpaSections(Context context) {
		ArrayList<SpaChildDTO> arrData = new ArrayList<SpaChildDTO>();
		String sql = "SELECT * FROM " + Constants.TBL_SPA_SECTION + "";
		DBHelper db = DBHelper.getInstance(context);
		Cursor c = db.Excutequery(sql);
		while (c.moveToNext()) {
			SpaChildDTO dto = new SpaChildDTO();
			dto.setSecId(c.getString(c.getColumnIndex("spa_section_id")));
			dto.setSecTitle(c.getString(c.getColumnIndex("spa_section_title")));
			dto.setSecTitleAr(c.getString(c
					.getColumnIndex("spa_section_title_ar")));
			dto.setSpaDesc(c.getString(c
					.getColumnIndex("spa_section_description")));
			dto.setSpaDescAr(c.getString(c
					.getColumnIndex("spa_section_description_ar")));
			dto.setSpaCatId(c.getString(c.getColumnIndex("spa_category_id")));
			dto.setSpaPackagePrice(c.getString(c
					.getColumnIndex("spa_section_pakage_price")));
			dto.setSpaTimeDuration(c.getString(c
					.getColumnIndex("spa_section_time_duration")));
			arrData.add(dto);
		}
		c.close();
		db.close();
		return arrData;
	}

	public ArrayList<SpaParentDTO> getAllSpaCategory(Context context) {
		ArrayList<SpaParentDTO> arrData = new ArrayList<SpaParentDTO>();

		String sql = "SELECT * FROM " + Constants.TBL_SPA_CATEGORY + "";
		DBHelper db = DBHelper.getInstance(context);
		Cursor c = db.Excutequery(sql);
		while (c.moveToNext()) {
			SpaParentDTO dto = new SpaParentDTO();
			dto.set_id(c.getString(c.getColumnIndex("spa_category_id")));
			dto.setSpaTitle(c.getString(c.getColumnIndex("spa_category_title")));
			dto.setSpaTitleAr(c.getString(c.getColumnIndex("spa_category_title_ar")));
			dto.setPriority(c.getString(c.getColumnIndex("priority")));
			arrData.add(dto);
		}
		c.close();
		db.close();
		return arrData;
	}

	// public ArrayList<SpaChildDTO> getSpaSection(String paramString,
	// Context context) {
	// ArrayList<SpaChildDTO> arrData = new ArrayList<SpaChildDTO>();
	//
	// String sql =
	// "SELECT * FROM spa_sections WHERE spa_section_title like= '%"+paramString+"%'";
	// DBHelper db = DBHelper.getInstance(context);
	// Cursor c = db.Excutequery(sql);
	// while (c.moveToNext()) {
	// SpaChildDTO dto = new SpaChildDTO();
	// dto.setSecId(c.getString(c.getColumnIndex("spa_section_id")));
	// dto.setSecTitle(c.getString(c.getColumnIndex("spa_section_title")));
	// dto.setSpaDesc(c.getString(c
	// .getColumnIndex("spa_section_description")));
	// dto.setSpaCatId(c.getString(c.getColumnIndex("spa_category_id")));
	// dto.setSpaPackagePrice(c.getString(c
	// .getColumnIndex("spa_section_pakage_price")));
	// dto.setSpaTimeDuration(c.getString(c
	// .getColumnIndex("spa_section_time_duration")));
	// arrData.add(dto);
	// }
	// c.close();
	// db.close();
	// return arrData;
	// }
}
